<template>
  <div>
    <div style="height: 40px;align-content: center" >
      <span style="color: red;font-size: 5px">*注意默认只查询当天的检查数据,如果要查询其它的,请选挥范围查询</span>
    </div>
    <el-tabs value="first" class="center-tabs" stretch="true">
      <el-tab-pane label="药品销售列表" name="first">
        <div class="app-container">
          <el-row :gutter="24">
            <!--用户数据-->
            <el-col :span="24" :xs="24">
              <!--搜索框-->
              <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
                <el-form-item label="药品名称" prop="drugName">
                  <el-input
                    v-model="queryParams.drugName"
                    placeholder="请输入药品名称"
                    clearable
                    size="small"
                    style="width: 240px"
                    @keyup.enter.native="handleQuery"
                  />
                </el-form-item>

                <el-form-item label="交易时间">
                  <el-date-picker
                    v-model="dateRange"
                    size="small"
                    style="width: 240px"
                    value-format="yyyy-MM-dd"
                    type="daterange"
                    range-separator="-"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                  ></el-date-picker>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                  <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                </el-form-item>
              </el-form>
              <el-table v-loading="loading" :data="drugsList" border show-summary>
                <el-table-column label="药品ID" align="center" key="drugId" prop="drugId"  />
                <el-table-column label="药品名称" align="center" key="drugName" prop="drugName"   />
                <el-table-column label="药品价格" align="center" key="drugPrice" prop="drugPrice"  />
                <el-table-column label="交易数量" align="center" key="salesNum" prop="salesNum"  />
                <el-table-column label="交易总价" align="center" key="salesAllmoney" prop="salesAllmoney"  />
                <el-table-column label="交易时间" align="center" key="createTime" prop="createTime"  />
              </el-table>
            </el-col>
          </el-row>
        </div>
      </el-tab-pane>
      <el-tab-pane label="药品销售统计列表" name="second">
        <div class="app-container">
          <el-row :gutter="24">
            <!--用户数据-->
            <el-col :span="24" :xs="24">
              <!--搜索框-->
              <el-form :model="queryParams1" ref="queryForm1" :inline="true" v-show="showSearch" label-width="68px">
                <el-form-item label="药品名称" prop="drugName">
                  <el-input
                    v-model="queryParams.drugName"
                    placeholder="请输入药品名称"
                    clearable
                    size="small"
                    style="width: 240px"
                    @keyup.enter.native="handleQuery1"
                  />
                </el-form-item>

                <el-form-item label="交易时间">
                  <el-date-picker
                    v-model="dateRange1"
                    size="small"
                    style="width: 240px"
                    value-format="yyyy-MM-dd"
                    type="daterange"
                    range-separator="-"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                  ></el-date-picker>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery1">搜索</el-button>
                  <el-button icon="el-icon-refresh" size="mini" @click="resetQuery1">重置</el-button>
                </el-form-item>
              </el-form>
              <el-table v-loading="loading" :data="drugsList1" border show-summary >
                <el-table-column label="药品ID" align="center" key="drugId" prop="drugId"  />
                <el-table-column label="药品名称" align="center" key="drugName" prop="drugName"   />
                <el-table-column label="交易总价" align="center" key="allsalesAllmoney" prop="allsalesAllmoney"/>
                <el-table-column label="交易数量" align="center" key="allsalesNum" prop="allsalesNum"  />
              </el-table>
            </el-col>
          </el-row>
        </div>
      </el-tab-pane>
  </el-tabs>
  </div>
</template>
<script>
  import { listDrugs,listDrugs1 } from "@/api/data/drugs/drugs";
  import Treeselect from "@riophae/vue-treeselect";
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";

  export default {
    name: "User",
    components: { Treeselect },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 用户表格数据
        drugsList: null,
        drugsList1: null,
        // 弹出层标题
        title: "",
        // 日期范围
        dateRange: [],
        dateRange1: [],
        // 状态数据字典
        statusOptions: [],
        // 查询参数
        queryParams: {
          drugName: undefined,
        },
        queryParams1: {
          drugName1: undefined,
        },
      };
    },
    created() {
      this.getList();
      this.getList1();
    },
    methods: {
      /** 查询用户列表 */
      getList() {
        this.loading = true;
        listDrugs(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
            this.drugsList = response.data;
            this.loading = false;
          }
        );
      },
      getList1() {
        this.loading = true;
        listDrugs1(this.addDateRange(this.queryParams1, this.dateRange)).then(response => {
            this.drugsList1 = response.data;
            this.loading = false;
          }
        );
      },

      /** 搜索按钮操作 */
      handleQuery() {
        this.getList();
      },
      handleQuery1() {
        this.getList1();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.dateRange = [];
        this.resetForm("queryForm");
        this.handleQuery();
      },
      resetQuery1() {
        this.dateRange1 = [];
        this.resetForm("queryForm1");
        this.handleQuery1();
      },
    }
  };
</script>
